<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title> - 注册</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico">
    <link href="css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="css/animate.css" rel="stylesheet">
    <link href="css/style.css?v=4.1.0" rel="stylesheet">
    <script>if (window.top !== window.self) { window.top.location = window.location; }</script>

</head>

<body class="gray-bg">

    <div class="middle-box text-center loginscreen   animated fadeInDown">
        <div>
            <div>

                <h1 class="logo-name">Dt+</h1>

            </div>
            <h3>欢迎注册 Dt+</h3>
            <p>该你选上场的小伙伴啦</p>
            <form class="m-t" role="form">
                <div class="form-group">
                    <input type="text" id="name-ipt" class="form-control" placeholder="请输入用户名" required="">
                </div>
                <div class="form-group">
                    <input type="password" id="password-ipt" class="form-control" placeholder="请输入密码" required="">
                </div>
                <div class="form-group">
                    <input type="password" id="rpassword-ipt"  class="form-control" placeholder="请再次输入密码" required="">
                </div>
                <div class="form-group">
                    <label>权限</label>
                    <select name="" class="form-control m-b" id="company-post">
                        <option value="0" selected>实习</option>
                        <option value="1">员工</option>
                        <option value="2">主管</option>
                        <option value="3">总监</option>
                    </select>
                </div>
                <div class="form-group">
                    <select name="" class="form-control m-b" id="partment">
                        <option value="1" selected>研发</option>
                        <option value="2">市场</option>
                        <option value="3">行政</option>
                        <option value="4">财务</option>
                        <option value="5">人事</option>
                    </select>
                </div>
                <div class="form-group">
                        <select name="" class="form-control m-b" id="sysrole">
                            <option value="1" selected>超级管理猿</option>
                            <option value="2">管理猿</option>
                            <option value="2">普通猿工</option>
                        </select>
                    </div>
                <div class="form-group text-left">
                    <div class="checkbox i-checks">
                        <label class="no-padding">
                            <input type="checkbox" id="accept-ipt"><i></i> 我同意注册协议</label>
                    </div>
                </div>
                <button type="button" class="btn btn-primary block full-width m-b" onclick="register()">注 册</button>

                <p class="text-muted text-center"><small>已经有账户了？</small><a href="login.html">点此登录</a>
                </p>

            </form>
        </div>
    </div>

    <!-- 全局js -->
    <script src="js/jquery.min.js?v=2.1.4"></script>
    <script src="js/bootstrap.min.js?v=3.3.6"></script>
    <!-- iCheck -->
    <script src="js/plugins/iCheck/icheck.min.js"></script>
    <script type="text/javascript"  src="js/host.js"></script>

    <script>
        $(document).ready(function () {
            $('.i-checks').iCheck({
                checkboxClass: 'icheckbox_square-green',
                radioClass: 'iradio_square-green',
            });
        });

        function register() {
            var username = $("#name-ipt").val();
            var password = $("#password-ipt").val();
            var rpassword = $("#rpassword-ipt").val();
            var company_post = $("#company-post").val();
            var partment = $("#partment").val();
            var sysrole = $("#sysrole").val();
            if($("input[type='checkbox']").attr('checked')==false){
                alert("你当用户协议是摆设吗");
            }
            if(password!=rpassword){
                alert("密码输两遍不会吗");
                return;
            }
            $.ajax({
                type: "POST",
                url: localhost + "/userManage/creatUser",
                data: '{ "oper_type":"0","user_name": "'+ username +'","user_passwd": "'+password+'","compang_post": '+company_post+',"partment": '+partment+',"sysrole":'+sysrole+'}',
                xhrFields: {
                    withCredentials: true
                },
                dataType: "json",
                success: function (data) {
                    if (data["response_msg"] == "success") {
                        alert("注册成功");
                    }else{
                        alert("注册失败:"+data["response_data"]);
                    }
                },error: function(data){
                    alert("注册失败")
                }
            });
        }
    </script>




</body>

</html>